const _ = require('lodash')

module.exports = (groups) => {
  const result = _.chain(groups)
    .orderBy(
      [
        // 连续错误段数
        (group) => group.stats.consecutiveIncorrectSegments,
        // 当前连续错误次数
        (group) => group.stats.currentConsecutiveIncorrect
      ],
      ['desc', 'desc']
    )
    .value()

  return result
}
